<template>
    <div>
        <c-table ref="tableRef" :page="{ limit, page, total }" :lists="tableData" @current-change="handleCurrentChange"
            @size-change="handleSizeChange" :loading="loading" :sequence="false" rowKey="id">
            <el-table-column align="center" label="操作人" width="150" prop="createName" />
            <el-table-column align="center" label="操作时间"  prop="createTime" />
            <el-table-column align="left" label="内容" prop="content" />
        </c-table>
    </div>
</template>
<script setup>
import {ref,onMounted} from "vue"
import{useRouter,useRoute} from "vue-router"
import { useUserStore } from '@/pinia/modules/user'
import {getPlantLogList} from '@/api/plant'
import {message} from '@/utils/element'
import { ElMessageBox } from 'element-plus'
import cTable from '@/components/custom/cTable.vue'

const router = useRouter()
const route = useRouter()
const userStore = useUserStore()

const page = ref(1)
const limit = ref(10)
const total = ref(0)
const plantHeaderId = ref('')
const tableData = ref([])
const loading = ref(true)
const tableRef = ref(null)

onMounted(()=>{
    plantHeaderId.value = route.currentRoute.value.query.plantHeaderId
    getTableData()
})

// 分页
const handleSizeChange = (val) => {
  page.value = 1
  limit.value = val
  getTableData()
}

const handleCurrentChange = (val) => {
  page.value = val
  getTableData()
}

// 查询
const getTableData = async () => {
  const res = await getPlantLogList({ 
    page: page.value, 
    limit: limit.value,
    plantHeaderId:plantHeaderId.value
  })
  if (res.code == 0) {
    tableData.value = res.data
    total.value = res.total
  }
  loading.value = false
}
</script>